<?php
namespace app\admin\controller;


use \think\Controller;
use \think\Db;
use \tp5er\Backup;
class Shujuku extends BaseController
{


    // 数据库备份列表
    public function shujukubeifen()
    {

        $db= new Backup(config('backup_config'));

        $this->assign('dblist',$db->fileList());
        //$tables="数据库表1";
        return $this->fetch();
    }
    //备份数据库
    public  function backup(){

        $db= new Backup(config('backup_config'));
        foreach($db->dataList() as $row){
            $file=['name'=>date('Ymd-His'),'part'=>1];
            $start= $db->setFile($file)->backup($row['name'], 0);
        }
        echo $start;

    }
    //删除备份
    public  function delFile(){

        $db= new Backup(config('backup_config'));
        $time=input('get.time');
       $ok= $db->delFile($time);
echo $ok;
    }
    //下载备份
    public  function downloadFile(){

        $db= new Backup(config('backup_config'));
        $time=input('get.time');
        $db->downloadFile($time);

    }
        //还原备份
public  function import(){

    $db= new Backup(config('backup_config'));
    $time=input('get.time');
    $file=$db->getFile('timeverif',$time);
    $start=0;
    $start= $db->setFile($file)->import($start);
    echo $start;
}



}
